<template>

  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="90px" style="padding-left: 10%;">
      <el-form-item label="分类名称:" prop="supplierClassifyName">
        <el-input v-model="form.supplierClassifyName"></el-input>
      </el-form-item>
      <el-form-item label="排序:" prop="sort">
        <el-input v-model="form.sort"></el-input>
      </el-form-item>
      <el-form-item label="状态:" prop="classStatus">
        <el-radio-group v-model="form.classStatus">
          <el-radio label="1">正常</el-radio>
          <el-radio label="0">隐藏</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import modelMixin from '@/mixins/modelMixin'
import { getClassifyAllList } from '@/api/goods/classify'
import classify from '@/api/goods/classify';
export default {
  name: "addForm",
  mixins: [modelMixin],
  data() {
    return {
      funcObj: classify,//方法对象
      open: false,
      title: "添加分类",
      form: {
        classStatus: '1',
        sort: '0',
        classifyType: '1'
      },
      rules: {
        supplierClassifyName: [
          { required: true, message: "请输入分类名称", trigger: "blur" }
        ]
      },
      classifyList: [],
    }
  },
  methods: {
    add(row) {
      this.open = true;
      this.form = {
        classifyType: '1',
        classStatus: '1',
        sort: '0'
      }
      if (row.id) {
        this.$set(this.form, 'parentId', row.id)
      }
    },

    /**
     * @编辑
     * @param {*} id 
     */
    edit(row) {
      this.title = "编辑分类";
      this.open = true;
      this.getDetail(row)
    },

    /** 转换数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.classifyName,
        children: node.children
      };
    },
  }
}
</script>

<style lang="scss" scoped></style>